package com.szqhyxj.youxiangju.biz.partnerHome.equipment.currentRecord;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.merchantHome.CustomViewPager;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CurrentRecordActivity extends AppCompatActivity implements NavigationBar.NavigationBarListener{

    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.storage)
    RadioButton storage;
    @BindView(R.id.issued)
    RadioButton issued;
    @BindView(R.id.activation)
    RadioButton activation;
    @BindView(R.id.card_chooser)
    RadioGroup cardChooser;
    @BindView(R.id.storage_line)
    RadioButton storageLine;
    @BindView(R.id.issued_line)
    RadioButton issuedLine;
    @BindView(R.id.activation_line)
    RadioButton activationLine;
    @BindView(R.id.card_chooser_Line)
    RadioGroup cardChooserLine;
    @BindView(R.id.custom)
    CustomViewPager custom;

    List<Fragment> fragmentList;

    public static void start(Activity activity){
        Intent intent = new Intent();
        intent.setClass(activity,CurrentRecordActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_current_record);
        ButterKnife.bind(this);
        navigationBar.setNavigationBarListener(this);
        fragmentList = new ArrayList<>();
        fragmentList.add(CurrentRecordFragment.newInstance(CurrentRecordModel.RECORD_TYPE));
        fragmentList.add(CurrentRecordFragment.newInstance(CurrentRecordModel.ACTIVATE_TYPE));
        fragmentList.add(CurrentRecordFragment.newInstance(CurrentRecordModel.OUT_TYPE));
        RecordFragmentAdapter adapter = new RecordFragmentAdapter(getSupportFragmentManager(), fragmentList);
        custom.setAdapter(adapter);
    }

    @Override
    public void navigationLeft(){
        finish();
    }

    @Override
    public void navigationRight(){
    }

    @OnClick({R.id.storage, R.id.issued, R.id.activation})
    public void onViewClicked(View view){
        switch(view.getId()){
            case R.id.storage:
                custom.setCurrentItem(0);
                break;
            case R.id.issued:
                custom.setCurrentItem(1);
                break;
            case R.id.activation:
                custom.setCurrentItem(2);
                break;
        }
    }
}
